package org.zzz.mapper;

import org.apache.ibatis.annotations.*;
import org.zzz.entity.Teacher;
import org.zzz.entity.TeacherVo;

import java.util.List;

/**
 * @Author ZZF
 * @Time 2021/04/20 22:24
 */
public interface TeacherMapper {
    /**
     * 添加教师信息
     * @param teacher
     * @return
     */
    @Insert("insert into teacher(id,name,gender,degree) value(#{id} , #{name}, #{gender}, #{degree})")
    int insertTeacher(Teacher teacher);

    /**
     * 删除教师信息
     * @param id
     * @return
     */
    @Delete("delete from teacher where id = #{id}")
    int deleteTeacherById(@Param("id") String id);

    /**
     * 获取所有教师信息
     * @return
     */
    @Select("select * from teacher")
    List<Teacher> listAllTeacher();

    /**
     * 根据工号获取教师信息
     * @param id
     * @return
     */
    @Select("select * from teacher where id = #{id}")
    Teacher getTeacherById(@Param("id") String id);

    /**
     * 根据教师姓名获取教师信息
     * @param name
     * @return
     */
    @Select("select * from teacher where name = #{name}")
    List<Teacher> getTeacherByName(@Param("name") String name);

    /**
     *
     * 更改教师信息
     * @param teacher
     * @return
     */
    @Update("update teacher set name = #{name}, gender = #{gender}, degree = #{degree} where id = #{id}")
    int updateTeacher(Teacher teacher);

    @Select("select name from teacher where id = #{id}")
    String getTeacherNameById(@Param("id") String id);

}
